# 48. 最少停车数
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.on('line', function(input) {
const inputArray = input.split(',');
const inputString = inputArray.join('');
const park = inputString.split('0');
let min = 0;
for(const slot of park) {
const occLen = slot.length;
if (occLen === 0) {
min = min;
} else if(occLen % 3 === 0 && occLen !== 0) {
min += Math.floor(occLen / 3);
} else if (occLen % 3 !== 0) {
min += Math.floor((occLen - occLen%3)/3);
min += 1;
}
}
console.log(min);
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24